package com.ruoyi.bom.service.impl;

import java.util.List;

import com.ruoyi.bom.domain.TqlStapBase;
import com.ruoyi.bom.mapper.TqlStapBaseMapper;
import com.ruoyi.common.core.utils.DateUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bom.mapper.TqlMaterialTransUnitMapper;
import com.ruoyi.bom.domain.TqlMaterialTransUnit;
import com.ruoyi.bom.service.ITqlMaterialTransUnitService;

/**
 * 物料单位转化表Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-28
 */
@Service
public class TqlMaterialTransUnitServiceImpl implements ITqlMaterialTransUnitService 
{
    @Autowired
    private TqlMaterialTransUnitMapper tqlMaterialTransUnitMapper;


    @Autowired
    private TqlStapBaseMapper tqlStapBaseMapper;

    /**
     * 查询物料单位转化表
     * 
     * @param id 物料单位转化表主键
     * @return 物料单位转化表
     */
    @Override
    public TqlMaterialTransUnit selectTqlMaterialTransUnitById(Long id)
    {
        return tqlMaterialTransUnitMapper.selectTqlMaterialTransUnitById(id);
    }

    public TqlMaterialTransUnit   selectTqlMaterialTransUnitByFMaterialIdfnumber(String id)
    {
        return tqlMaterialTransUnitMapper.selectTqlMaterialTransUnitByFMaterialIdfnumber(id);
    }

    /**
     * 查询物料单位转化表列表
     * 
     * @param tqlMaterialTransUnit 物料单位转化表
     * @return 物料单位转化表
     */
    @Override
    public List<TqlMaterialTransUnit> selectTqlMaterialTransUnitList(TqlMaterialTransUnit tqlMaterialTransUnit)
    {
        return tqlMaterialTransUnitMapper.selectTqlMaterialTransUnitList(tqlMaterialTransUnit);
    }

    /**
     * 新增物料单位转化表
     * 
     * @param tqlMaterialTransUnit 物料单位转化表
     * @return 结果
     */
    @Override
    public int insertTqlMaterialTransUnit(TqlMaterialTransUnit tqlMaterialTransUnit)
    {
        tqlMaterialTransUnit.setCreateTime(DateUtils.getNowDate());
        TqlStapBase tqlStapBase=new TqlStapBase();
        String stapCode=tqlMaterialTransUnit.getFMaterialIdfnumber();
        String auxUnit=tqlMaterialTransUnit.getFDestUnitIdfname();
        tqlStapBase.setStapCode(stapCode);
        tqlStapBase.setStapAuxUnit(auxUnit);
        tqlStapBaseMapper.updateTqlStapBaseAunxUnitByStapCode(tqlStapBase);
        return tqlMaterialTransUnitMapper.insertTqlMaterialTransUnit(tqlMaterialTransUnit);
    }

    /**
     * 修改物料单位转化表
     * 
     * @param tqlMaterialTransUnit 物料单位转化表
     * @return 结果
     */
    @Override
    public int updateTqlMaterialTransUnit(TqlMaterialTransUnit tqlMaterialTransUnit)
    {
        return tqlMaterialTransUnitMapper.updateTqlMaterialTransUnit(tqlMaterialTransUnit);
    }

    /**
     * 批量删除物料单位转化表
     * 
     * @param ids 需要删除的物料单位转化表主键
     * @return 结果
     */
    @Override
    public int deleteTqlMaterialTransUnitByIds(Long[] ids)
    {
        return tqlMaterialTransUnitMapper.deleteTqlMaterialTransUnitByIds(ids);
    }

    /**
     * 删除物料单位转化表信息
     * 
     * @param id 物料单位转化表主键
     * @return 结果
     */
    @Override
    public int deleteTqlMaterialTransUnitById(Long id)
    {
        return tqlMaterialTransUnitMapper.deleteTqlMaterialTransUnitById(id);
    }
}
